package fudan.se.lab2.controller;

import fudan.se.lab2.controller.request.ApproveRequest;
import fudan.se.lab2.domain.Meeting;
import fudan.se.lab2.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AdminController {
    private final AdminService adminService;

    @Autowired
    public AdminController(AdminService adminService) {
        this.adminService = adminService;
    }

    @PostMapping("/approveMeeting")
    public ResponseEntity<Meeting> approve(@RequestBody ApproveRequest request) {
        return ResponseEntity.ok(adminService.approve(request));
    }

    @PostMapping("/rejectMeeting")
    public ResponseEntity<Meeting> reject(@RequestBody ApproveRequest request) {
        return ResponseEntity.ok(adminService.reject(request));
    }

    @PostMapping("/meetingToBeApproved")
    public ResponseEntity<List<Meeting>> meetingToBeApproved() {
        return ResponseEntity.ok(adminService.meetingToBeApproved());
    }

    @PostMapping("/meetingAlreadyApproved")
    public ResponseEntity<List<Meeting>> meetingAlreadyApproved() {
        return ResponseEntity.ok(adminService.meetingAlreadyApproved());
    }
}
